package 方法重写;

public class Son extends Person{
    String sex;

    public Son() {

    }

    public Son(String name, int age, String sex) {
        this.name=name;
        setAge(age);
        this.sex = sex;
    }
    @Override
    public void eat(){
        System.out.println("吃饭喝水");

    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public static void main(String[] args) {
        Person p=new Person();
        Person p2=new Son();
        p.eat();
        System.out.println("-----------");
        p2.eat();
        System.out.println(p2.name="Tom");
    }
}
